package com.dindang.propertyfee.mvp.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.dindang.propertyfee.R;
import com.dindang.propertyfee.di.component.DaggerPropertyFeeRecordComponent;
import com.dindang.propertyfee.di.module.PropertyFeeRecordModule;
import com.dindang.propertyfee.mvp.contract.PropertyFeeRecordContract;
import com.dindang.propertyfee.mvp.presenter.PropertyFeeRecordPresenter;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.longxi.gamer_base.widget.EmptyLayout;

import in.srain.cube.views.ptr2.PtrClassicFrameLayout;

import static com.jess.arms.utils.Preconditions.checkNotNull;


public class PropertyFeeRecordFragment extends BaseFragment<PropertyFeeRecordPresenter> implements PropertyFeeRecordContract.View {

    PtrClassicFrameLayout mPtrclassicframelayout;
    RecyclerView mRecyclerview;
    EmptyLayout mEmptyLayout;
    View view;

    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {
        DaggerPropertyFeeRecordComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .propertyFeeRecordModule(new PropertyFeeRecordModule(this))
                .build()
                .inject(this);
    }

    @Override
    public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.propertyfee_fragment_property_fee_record, container, false);
        return view;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mPtrclassicframelayout = view.findViewById(R.id.propertyfee_ptrclassicframelayout);
        mRecyclerview = view.findViewById(R.id.propertyfee_recyclerview);
        mEmptyLayout = view.findViewById(R.id.propertyfee_emptyLayout);

        mPresenter.init();
    }

    @Override
    public void setData(@Nullable Object data) {
        mPresenter.setData(data);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {

    }

    @Override
    public PtrClassicFrameLayout getPtrclassicframelayout() {
        return mPtrclassicframelayout;
    }

    @Override
    public RecyclerView getRecyclerview() {
        return mRecyclerview;
    }

    @Override
    public EmptyLayout getEmptyLayout() {
        return mEmptyLayout;
    }

    @Override
    public Fragment getFragment() {
        return this;
    }
}
